package com.gufe.controller.user.mp.quiz;

import com.gufe.entity.wxUsers;
import com.gufe.result.Result;
import com.gufe.service.user.mp.quiz.WxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/quiz/user") // 使用 /api/quiz/user 作为路径前缀
public class QuizUserController {

    @Autowired
    private WxUserService wxUserService;

    @GetMapping("/info")
    public Result<wxUsers> getUserInfo(@RequestHeader("Authorization") String token) {
        wxUsers user = wxUserService.getUserByToken(token);
        if (user != null) {
            return Result.success(user);
        } else {
            return Result.error("未授权"); // 未授权
        }
    }
}